﻿<%@ Page Language="C#" MasterPageFile="~/Manager.master" AutoEventWireup="true" CodeFile="ChangeEmail.aspx.cs" Inherits="Manager_PrivateInfo_ChangeEmail"  %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table border="1" cellpadding="2" cellspacing="2" class="tbl_Comon-Search" style="width: 100%">
        <tr>
            <td align="left" class="td_Control" colspan="2">
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="grpAdd" />
            </td>
        </tr>
        <tr>
            <td class="td_Title" style="width: 158px">
                <asp:Label ID="Label6" runat="server" Text="Nhập địa chỉ Email mới"></asp:Label></td>
            <td align="left" class="td_Control" nowrap="nowrap">
                <asp:TextBox ID="txtEmail" runat="server" onblur="fnCheckEmail(this.value)" onkeyup="fnHideImgEmail()"
                    ValidationGroup="grpAdd" Width="50%"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtEmail"
                    ErrorMessage="Nhập địa chỉ Email" ValidationGroup="grpAdd">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                    ErrorMessage="Địa chỉ Email chưa chính xác" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                    ValidationGroup="grpValid">*</asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator51" runat="server" ControlToValidate="hidEmail"
                    ErrorMessage="Địa chỉ Email này đã tồn tại" InitialValue="0" ValidationGroup="grpAdd"> &nbsp;</asp:RequiredFieldValidator>&nbsp;
                <img id="imgStateEmail" border="0" src="../../Images/Icon/spinner.gif" style="visibility: hidden" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator52" runat="server" ControlToValidate="hidEmail"
                    ErrorMessage="Đang xử lý..." ValidationGroup="grpAdd">Đang xử lý...</asp:RequiredFieldValidator>
                <asp:TextBox ID="hidEmail" runat="server" CssClass="cssHidden" Text="0" Width="5px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="td_Title" style="width: 158px">
                <asp:Label ID="Label1" runat="server" Text="Xác nhận lại địa chỉ Email"></asp:Label></td>
            <td align="left" class="td_Control" nowrap="nowrap">
                <asp:TextBox ID="txtPreEmail" runat="server"
                    ValidationGroup="grpAdd" Width="50%"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtEmail"
                    ControlToValidate="txtPreEmail" ErrorMessage="Địa chỉ Email chưa khớp nhau" ValidationGroup="grpAdd">*</asp:CompareValidator>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPreEmail"
                    ErrorMessage="Nhập địa chỉ Email xác nhận" ValidationGroup="grpAdd">*</asp:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td align="left" colspan="2" style="padding-left: 125px">
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 158px">
            </td>
            <td align="left" style="height: 24px">
                <!--<asp:Button ID="btnAdd_ChuDe" runat="server" Text="Thêm mới" CssClass="cssButton" />-->
                <asp:Button ID="btnAdd" runat="server" CssClass="cssButton" OnClick="btnAdd_Click"
                    Text="Bảo lưu" ValidationGroup="grpAdd" Width="80px" />
                </td>
        </tr>
    </table>
    
 <script language="javascript" type="text/javascript">   
    /*=================Email================*/
    String.prototype.trim = function () {
		return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}
    function fnHideImgEmail()
    {
        var imgStateEmail=document.getElementById("imgStateEmail");
        imgStateEmail.style.visibility="hidden"; 
    }
    function fnCheckEmail(sValue)
    {      
        if(sValue.trim()=="")  return;
        Manager_PrivateInfo_ChangeEmail.AjaxCheckEmail(sValue,CallBackEmail);  

     
    }
    function CallBackEmail(res)
    {
        if(res!=null)
        {
            var flag=res.value;
            if(flag!=null && flag!="")
			{	
			    var imgStateEmail=document.getElementById("imgStateEmail");

			    var hidEmail=document.getElementById("<%= hidEmail.ClientID%>");
			    hidEmail.value="aaa"; //Tranh su kien dang su ly
		
			    if(flag=="yes")
			    {   imgStateEmail.style.visibility="visible";
			        imgStateEmail.src="../../Images/Icon/cmdDelete.gif";
			        imgStateEmail.alt="Email này đã tồn tại";			        
			        hidEmail.value="0";
			       
			    }		
			    else
			    {
			           imgStateEmail.style.visibility="hidden";
			    }	    
			}	
        }
    }

 
 </script>
    
</asp:Content>

